//
//  XKLMeCollectionViewCell.m
//  GuiZiShouDuanZi
//
//  Created by xmg on 16/4/29.
//  Copyright © 2016年 xiao_kl. All rights reserved.
//

#import "XKLMeCollectionViewCell.h"
#import "XKLMeItem.h"
#import <UIImageView+WebCache.h>

@interface XKLMeCollectionViewCell()
@property (nonatomic,weak)UIImageView *imageView;
@property (nonatomic,weak)UILabel *name;
@end

@implementation XKLMeCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *imageView=[[UIImageView alloc] init];
        [self addSubview:imageView];
        self.imageView=imageView;
        UILabel *label=[[UILabel alloc] init];
        [self addSubview:label];
        self.name=label;
        label.textAlignment=NSTextAlignmentCenter;
        self.backgroundColor=[UIColor whiteColor];
    }
    return self;
}


-(void)setItem:(XKLMeItem *)item{
    _item=item;
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:item.icon]placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]];
    self.name.text=item.name;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.imageView.frame=CGRectMake(self.width*0.25, 10, self.width*0.5, self.height*0.5);
    
    self.name.frame=CGRectMake(0, self.height*0.5+10, self.width, self.height*0.3);
    
    
}
@end
